package recycle.controller;

import recycle.pojo.Hotcomment;
import recycle.service.HotcommentService;
import recycle.utils.Page;
import recycle.vo.HotcommentParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 描述：热门商品评论表 控制器
* @author 孙冉
* @date 2019/07/22
*/
@RestController
@RequestMapping("/hotcomment")
public class HotcommentController{
	@Resource
	private HotcommentService hotcommentService;
 	
 	@RequestMapping("/findById.json")
    public Hotcomment findById(Integer hotCommentId){
        Hotcomment result = null;
        try {
            result = hotcommentService.findById(hotCommentId);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：获取所有的Hotcomment对象
     */
    @RequestMapping("/findAllHotcomment.json")
    public List<Hotcomment> findAllHotcomment(){
        List<Hotcomment> result = null;
        try {
            result = hotcommentService.findAll();
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：新增保存Hotcomment对象
     */
    @RequestMapping("/save.json")
    public Map save(Hotcomment hotcomment){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","保存热门商品评论表失败");
        try {
            if(hotcommentService.save(hotcomment)>0){
                result.put("flag",true);
                result.put("msg","保存热门商品评论表成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：根据主键删除热门商品评论表对象
     * @param hotCommentId
     */
    @RequestMapping("/delete.json")
    public Map delete(Integer hotCommentId){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","保存热门商品评论表失败");
        try {
            if(hotcommentService.delete(hotCommentId)>0){
                result.put("flag",true);
                result.put("msg","保存热门商品评论表成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：更新热门商品评论表对象
     */
    @RequestMapping("/update.json")
    public Map update(Hotcomment hotcomment){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","更新热门商品评论表失败");
        try {
            if( hotcommentService.update(hotcomment)>0){
                result.put("flag",true);
                result.put("msg","更新热门商品评论表成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;

    }

    /**
     * 根据不确定的条件，动态查询
     */
    @RequestMapping("/query.json")
    public List<Hotcomment> query(HotcommentParam param){
        List<Hotcomment> result = null;
        try {
            result = hotcommentService.query(param);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 根据不确定的条件，动态分页查询
     */
    @RequestMapping("/queryByPage.json")
    public Page queryByPage(HotcommentParam param){
        Page result = null;
        try {
            result = hotcommentService.queryByPage(param);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }
 }
